const BaseUrl = "http://192.168.25.58:8000";
function http({url,method="get",data={}}){
   // header的值不是传进来的，根据分析得来如果是get  如果是post请求
    let header = {
        "content-type":"application/json"
    }
    if(method.toLowerCase() == 'post'){
        header = {
            "content-type":"application/x-www-form-urlencoded"
        }
    }
    wx.showLoading({
      title: '数据正在加载中',
    })
    return new Promise((resolve,reject)=>{
        wx.request({
          url:BaseUrl + url,
          method,
          data,
          header,
          success:(res)=>{
              resolve(res);
          },
          fail:(err)=>{
              reject(err);
          },
          complete:()=>{
              console.log('接口调用完毕');
              wx.hideLoading();
          }
        })
    })
}

module.exports = {
    http,
}